Helpful Information
 
 
Category: MSSQL
PHP --> MSSQL --> unique identifier problem

Hello all,

Hopefully this is not recycled stuff:

I'm currently building an app using PHP from a Linux box calling to SQL Server, using the mssql functions in PHP, and it's working out great, except when I wish to garner a RecID that is of type unique identifier in the SQL Server database. When I attempt to get these values, my queries just junk out.

I'm thinking I need to make a conversion along the way, but am not sure where to assign the conversion. Perhaps when I fetch the entire array, or maybe better yet just when I call ["RecID"].

Any help or suggested resources would be great.

thanks.

I'm assuming you're using FreeTDS to connect to the SQL Server. We had the same problem and solved it by altering our SQL statements to use CONVERT to convert UNIQUEIDENTIFIER type to VARCHAR as in

SELECT CONVERT(VARCHAR(36), RecID) AS 'RecID' FROM table

thank you. I was close but wasn't quite thinking correctly. Makes sense as PHP, even as I am somewhat new, usually makes perfect sense.

Sorry to clutter the board with a thanks, but this site has already saved me weeks of work. It, and www.php.net, far surpass any contract support from certain companies.










privacy (GDPR)